﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.DAL;
using Wp.BLL;

public partial class Modules_Posts_Controls_ListPost : System.Web.UI.UserControl
{
    public static int PAGE_SIZE = 20;
    public string CategoryName { get; set; }
    public string CategoryTextId { get; set; }
    public int PageIndex { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        PageIndex = CommonHelper.QueryStringInt("PageIndex", 1);
        CategoryTextId = CommonHelper.QueryString("CategoryTextId", "");
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    void LoadData()
    {
        TblTermsEntity item = TblTermsManager.CreateInstant().SelectOneSlug(CategoryTextId);
        if (item != null)
            CategoryName = item.Name;
        else CategoryName = "";
        int TotalRow = 0;
        List<TblPostsEntity> ls = TblPostsManager.CreateInstant().SelectTblPostByPostType("post", CategoryTextId, "category", PAGE_SIZE, PageIndex, out TotalRow);
        rpt.DataSource = ls;
        rpt.DataBind();
    }
}